﻿using System;
using System.Web.UI.WebControls;
using Ue.Infrastructure.DomainBase;
using Ue.Infrastructure.RepositoryFramework;
using Ue.Infrastructure.Web.UI;
using Ue.Qcdz.Domain.Collectors;

namespace Ue.Qcdz.UI.Controls
{
    public class CollectorGridView : SkinnedGridView, ICollectorDataQuery, Ue.Infrastructure.DomainBase.ISort
    {

        private ICollectorRepository repository;

        public CollectorGridView()
        {
            this.repository = RepositoryFactory.GetRepository<ICollectorRepository, Collector>();
        }

        protected override void GridViewDataBind(object sender, EventArgs args)
        {
            IDataResult<Collector> dataResult = this.repository.FindBy(this);
            this.RecordCount = dataResult.RecordCount;
            Repeater repeater = sender as Repeater;
            repeater.DataSource = dataResult.DataObjects;
            repeater.DataBind();
        }

        protected override string GetSkinFileName()
        {
            return "~/Admin/Themes/Skins/Collectors/Collectors.ascx";
        }
        #region ICollectorDataQuery 成员

        public bool Status
        {
            get;
            set;
        }

        #endregion

        #region ISort 成员

        public string BuildSortStatement()
        {
            return "ID DESC";
        }

        #endregion
    }
}
